//
//  BiaoGeCell.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/5/2.
//  Copyright © 2017年 金橙云. All rights reserved.
//

#define WIDTH_W [UIScreen mainScreen].bounds.size.width
#define EVERY_W ([UIScreen mainScreen].bounds.size.width)/5

#import "BiaoGeCell.h"

@implementation BiaoGeCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        
        self.dataArr = [NSArray new];
        _baoLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDTH_W, 30)];
        _baoLab.backgroundColor = [UIColor orangeColor];
        _baoLab.text = @"    认购日报(套)";
        _baoLab.textColor = [UIColor whiteColor];
        _baoLab.font = [UIFont systemFontOfSize:14];
        [self addSubview:_baoLab];
        
        _chatView = [[ListChartView alloc] initWithFrame:CGRectMake(0, 30, WIDTH_W, 300)];
        [_chatView setBorderWidth:1.0f];
        [_chatView setDelegate:self];
        [self addSubview:_chatView];
        [_chatView reloadData];

        NSLog(@"dataArr===%@",self.dataArr);

        if (self.dataArr.count!=0) {
             NSLog(@"dataArr===%@",self.dataArr[0]);
        }

    }
    return self;
}


-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 1;
}
-(NSInteger)rowForList:(ListChartView *)list
{
    if (self.dataArr.count!=0) {
        return [self.dataArr[0] count]+1;

    }
    return 0;
}
-(NSInteger)columnForList:(ListChartView *)list
{
    
    if (self.dataArr.count!=0) {
        return [self.dataArr[2] count];
        
    }
    return 0;

}

-(UIColor*)listChart:(ListChartView *)list textColorForRow:(NSInteger)row column:(NSInteger)column
{
    if (self.dataArr.count!=0) {
        if (row == 0 || column == 0)
        {
            return [UIColor orangeColor];
        }
        
    }
    
    return nil;
}

-(CGSize)listChart:(ListChartView *)list itemSizeForRow:(NSInteger)row column:(NSInteger)column
{
    return CGSizeMake(EVERY_W, 33.0f);
}

-(NSString*)listChart:(ListChartView *)list textForRow:(NSInteger)row column:(NSInteger)column
{
    //  cell.dataArr = @[_zuoyishuArr,_nozuiyiArr,_hengyiArr];
    if (self.dataArr.count!=0) {

    if (row == 0)
    {
        for (int i=0; i<[self.dataArr[2] count]; i++) {
            
            IF_T_FF(row, column, 0, i){return self.dataArr[2][i];}
            
        }
        
    }
    else if (column == 0)
    {
        for (int i=0; i<[self.dataArr[0]count]; i++) {
            IF_T_FF(row, column, i+1, 0)
            {return self.dataArr[0][i];}
            
        }
        
    }
    if (row!=0) {
        for (int h=1; h<[self.dataArr[1]count]+1; h++) {//_zuoyishuArr.count == 10
            for (int i=1; i<[self.dataArr[2]count]+1; i++) { //_hengyiArr.count==5
                IF_T_FF(row, column, h, i){return [NSString stringWithFormat:@"%@",self.dataArr[1][h-1][i-1]];}
                
                
            }
            
        }
        
    }
    else{
        return 0;
    }
        
    }
    return 0;

}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
